package io.sdph.view;

import java.util.ArrayList;

/**
 * Klasa reprezentujaca sidebar
 * @author MODUL FRONTU (WWW)
 *
 */
public class SidebarPanel {

	ArrayList<SidebarElement> elements;	
	
	
	/**
	 * Konstruktor dla sidebaru (tworzacy przykladowe elementy)
	 */
	public SidebarPanel() {
		elements = new ArrayList<SidebarElement>();
		
		elements.add(new SidebarElement(elements.size(), "Quick contact", "some text..."));
	}
	
	/**
	 * Metoda dodajaca sidebarElement do sidebaru 
	 * @param String title
	 * @param String content
	 */
	public void add(String title, String content) {
		elements.add(new SidebarElement(elements.size()-1, title, content));
	}
	
	/**
	 * Metoda usuwajaca konkretny element sidebaru 
	 * @param SidebarElement elem
	 */
	public void remove(SidebarElement elem) {
		elements.remove(elem.id);
	}
	
	/**
	 * Metoda usuwajaca element sidebaru o konkretnym id
	 * @param int id
	 */
	public void remove(int id) {
		elements.remove(id);
	}
	
	/**
	 * Getter pobierajacy wszystkie elementy sidebaru
	 * @return ArrayList<String[]> tempElements
	 */
	public ArrayList<String[]> getSidebarElements() {
		
		ArrayList<String[]> tempElements = new ArrayList<String[]>();
		
		for (SidebarElement element : elements) {
			String[] temp = {Integer.toString(element.id), element.title, element.content};
			tempElements.add(temp);
		}			
		
		return tempElements;
		
	}
	
}
